package com.example.shop.controller;

import com.example.shop.model.req.CartDTO;
import com.example.shop.model.req.CartSkuDTO;
import com.example.shop.model.resp.CartDetail;
import com.example.shop.service.CartService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/cart")
@RequiredArgsConstructor
public class CartController {

    private final CartService cartService;

    @GetMapping("/v2/list")
    public List<CartDetail> listCart() {
        return cartService.listCart();
    }

    @PostMapping("/v2/add")
    public void addCart(@RequestBody CartDTO cartDTO) {
        cartService.addOrEditCart(cartDTO);
    }

    @PostMapping("/v2/edit")
    public void editCart(@RequestBody CartDTO cartDTO) {
        cartService.addOrEditCart(cartDTO);
    }

    @PostMapping("/v2/delete")
    public void deleteCart(@RequestBody CartSkuDTO cartSkuDTO) {
        cartService.deleteCart(cartSkuDTO);
    }

}
